package com.hzh.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzh.entity.User;
import com.hzh.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author NieChangan
 * @since 2021-08-26
 */
@Api(tags = "用户管理")
@RestController
@RequestMapping("/user")
public class UserController {
        @Autowired
        private UserService userService;
        @ApiOperation(value = "分页查询" ,notes = "详情描述一下该方法的作用")
        @GetMapping("list")
        /*
        * 分页查询
        * */
        Page<User> list(){
            Page<User> page=new Page<User>(1,3);
            Page<User> userPage = userService.page(page);
            return  userPage;
        }
         @GetMapping("userPage")
         @ApiOperation(value = "条件查询" ,notes = "详情描述一下该方法的作用")
        List<User> userPage(){
            QueryWrapper<User> wrapper=new QueryWrapper<User>();
            wrapper.like("username","xiaoge");
            List<User> userPage = userService.list(wrapper);
            return  userPage;
    }
}

